Stack CreateStack( int MaxSize ){
	Stack S;
	S = (Stack)malloc(sizeof(struct SNode));
	S->Data = (ElementType *)malloc(sizeof(ElementType)*MaxSize);
	S->MaxSize = MaxSize;
	S->Top1 = -1;
	S->Top2 = S->MaxSize;
	return S;
}
bool Push( Stack S, ElementType X, int Tag ){
	if(S == NULL)return false;
	if(S->Top2 - S->Top1 == 1){
		printf("Stack Full\n");
		return false;
	}
	if(Tag == 1){
		S->Data[++(S->Top1)] = X;
		return true;
	}
	else{
		S->Data[--(S->Top2)] = X;
		return true;
	}
	return false;
}
ElementType Pop( Stack S, int Tag ){
  if(S == NULL)return false;
	if(Tag == 1){
		if(S->Top1 == -1){
			printf("Stack %d Empty\n",Tag);
			return ERROR;
		}
		return S->Data[(S->Top1)--];
	}
	else if(Tag == 2){
		if(S->Top2 == S->MaxSize){
			printf("Stack %d Empty\n",Tag);
			return ERROR;
		}
		return S->Data[(S->Top2)++];
	}
	return false;
}
